<template>
  <header class="header">
    <h1>todos</h1>
    <input id="toggle-all" class="toggle-all" type="checkbox" v-model="typeCheck">
    <label for="toggle-all"></label>
    <input
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      autofocus
      @keydown.enter="enterFn"
      v-model="keyWords"
    />
  </header>
</template>

<script>
export default {
  props:{
    newArr:[]
  },
  data(){
    return{
      keyWords:'',
    }
  },
 methods:{
  enterFn(){
    this.keyWords.trim()===''?alert('请正确输入'):
    this.$emit('headFn',this.keyWords)
    this.keyWords=''
  }
 },
 computed:{
  typeCheck:{
    set(val){
      this.newArr.forEach(item=>item.isDone=val)
    },
    get(){
      return this.newArr.every(item=>item.isDone===true)
    }
  }
 }
}
</script>